package com.example.springconfig.demos.config;

import com.example.springconfig.demos.model.User;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

/**
 * Created with IntelliJ IDEA
 * Description
 * User: 晓星航
 * Date: 2024 -04 -14
 * Time: 15:07
 */
@Configuration
public class BeanConfig {
    @Bean
    public User user1() {
        return new User(1,"zhangsan");
    }

    @Scope("singleton")
    @Bean()
    public User singleUser() {
        return new User();
    }
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    @Bean
    public User prototypeUser() {
        return new User();
    }
    @RequestScope
    @Bean
    public User requestUser() {
        return new User();
    }
    @SessionScope
    @Bean
    public User sessionUser() {
        return new User();
    }
    @ApplicationScope
    @Bean
    public User applicationUser() {
        return new User();
    }


}
